package com.lysh.simple;

import org.assertj.core.util.Strings;
import org.springframework.util.StreamUtils;

import java.io.*;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;

/**
 * @author liyishan
 * @date 2023/8/4 15:45
 * @apiNote
 */

public class FileUtils {
    public static final int BUFFER_SIZE = 4096;


    //---------------------------------------------------------------------
    // Copy methods for java.io.File
    //---------------------------------------------------------------------

    /**
     * Copy the contents of the given input File to the given output File.
     *
     * @param in  the file to copy from
     * @param out the file to copy to
     * @return the number of bytes copied
     * @throws IOException in case of I/O errors
     */
    public static int copy(File in, File out) throws IOException {
        return copy(new BufferedInputStream(new FileInputStream(in)),
                new BufferedOutputStream(new FileOutputStream(out)));
    }

    /**
     * Copy the contents of the given byte array to the given output File.
     *
     * @param in  the byte array to copy from
     * @param out the file to copy to
     * @throws IOException in case of I/O errors
     */
    public static void copy(byte[] in, File out) throws IOException {
        ByteArrayInputStream inStream = new ByteArrayInputStream(in);
        OutputStream outStream = new BufferedOutputStream(new FileOutputStream(out));
        copy(inStream, outStream);
    }

    /**
     * Copy the contents of the given input File into a new byte array.
     *
     * @param in the file to copy from
     * @return the new byte array that has been copied to
     * @throws IOException in case of I/O errors
     */
    public static byte[] copyToByteArray(File in) throws IOException {
        return copyToByteArray(new BufferedInputStream(new FileInputStream(in)));
    }


    //---------------------------------------------------------------------
    // Copy methods for java.io.InputStream / java.io.OutputStream
    //---------------------------------------------------------------------

    /**
     * Copy the contents of the given InputStream to the given OutputStream.
     * Closes both streams when done.
     *
     * @param in  the stream to copy from
     * @param out the stream to copy to
     * @return the number of bytes copied
     * @throws IOException in case of I/O errors
     */
    public static int copy(InputStream in, OutputStream out) throws IOException {
        try {
            return StreamUtils.copy(in, out);
        } finally {
            try {
                in.close();
            } catch (IOException ex) {
            }
            try {
                out.close();
            } catch (IOException ex) {
            }
        }
    }

    /**
     * Copy the contents of the given byte array to the given OutputStream.
     * Closes the stream when done.
     *
     * @param in  the byte array to copy from
     * @param out the OutputStream to copy to
     * @throws IOException in case of I/O errors
     */
    public static void copy(byte[] in, OutputStream out) throws IOException {
        try {
            out.write(in);
        } finally {
            try {
                out.close();
            } catch (IOException ex) {
            }
        }
    }

    /**
     * Copy the contents of the given InputStream into a new byte array.
     * Closes the stream when done.
     *
     * @param in the stream to copy from
     * @return the new byte array that has been copied to
     * @throws IOException in case of I/O errors
     */
    public static byte[] copyToByteArray(InputStream in) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
        copy(in, out);
        return out.toByteArray();
    }


    //---------------------------------------------------------------------
    // Copy methods for java.io.Reader / java.io.Writer
    //---------------------------------------------------------------------

    /**
     * Copy the contents of the given Reader to the given Writer.
     * Closes both when done.
     *
     * @param in  the Reader to copy from
     * @param out the Writer to copy to
     * @return the number of characters copied
     * @throws IOException in case of I/O errors
     */
    public static int copy(Reader in, Writer out) throws IOException {
        try {
            int byteCount = 0;
            char[] buffer = new char[BUFFER_SIZE];
            int bytesRead = -1;
            while ((bytesRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, bytesRead);
                byteCount += bytesRead;
            }
            out.flush();
            return byteCount;
        } finally {
            try {
                in.close();
            } catch (IOException ex) {
            }
            try {
                out.close();
            } catch (IOException ex) {
            }
        }
    }

    /**
     * Copy the contents of the given String to the given output Writer.
     * Closes the writer when done.
     *
     * @param in  the String to copy from
     * @param out the Writer to copy to
     * @throws IOException in case of I/O errors
     */
    public static void copy(String in, Writer out) throws IOException {
        try {
            out.write(in);
        } finally {
            try {
                out.close();
            } catch (IOException ex) {
            }
        }
    }

    /**
     * Copy the contents of the given Reader into a String.
     * Closes the reader when done.
     *
     * @param in the reader to copy from
     * @return the String that has been copied to
     * @throws IOException in case of I/O errors
     */
    public static String copyToString(Reader in) throws IOException {
        StringWriter out = new StringWriter();
        copy(in, out);
        return out.toString();
    }

    /**
     * 将InputStream写入到File中
     *
     * @param ins
     * @param file
     * @throws IOException
     */
    public static void inputstreamtofile(InputStream ins, File file) throws IOException {
        OutputStream os = new FileOutputStream(file);
        int bytesRead = 0;
        byte[] buffer = new byte[8192];
        while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
            os.write(buffer, 0, bytesRead);
        }
        os.close();
        ins.close();
    }

    /**
     * 根据URL下载文件并保存到本地指定位置
     *
     * @param url         外部URL
     * @param saveAddress 本地指定位置
     */
    public static void downloadFile(String url, String saveAddress) {
        try {
            URL fileUrl = new URL(url);
            InputStream is = fileUrl.openStream();
            OutputStream os = new FileOutputStream(saveAddress);
            byte bf[] = new byte[1024];
            int length = 0;
            while ((length = is.read(bf, 0, 1024)) != -1) {
                os.write(bf, 0, length);
            }
            is.close();
            os.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 根据byte数组，生成文件
     * filePath  文件路径
     * fileName  文件名称（需要带后缀，如*.jpg、*.java、*.xml）
     */
    public static void createFile(byte[] qrData, String filePath, String fileName) {
        OutputStream os = null;
        try {

            File dir = new File(filePath);
            //判断文件目录是否存在
            if (!dir.exists() && dir.isDirectory()) {
                dir.mkdirs();
            }

            os = new FileOutputStream(filePath + fileName);
            os.write(qrData, 0, qrData.length);
            os.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (os != null) {
                try {
                    os.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }

    /**
     * <p>将文件转成base64 字符串</p>
     *
     * @param file 文件
     * @return
     * @throws Exception
     */
    public static String encodeBase64File(File file) {
        try {
            FileInputStream inputFile = new FileInputStream(file);
            byte[] buffer = new byte[(int) file.length()];
            inputFile.read(buffer);
            inputFile.close();
            return Base64.getEncoder().encodeToString(buffer);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("文件转成base64 字符串异常");
        }
    }

    /**
     * 将base64图片解析成文件存放本地
     *
     * @param imgStr
     * @return 本地临时文件的地址
     */
    private static String generateImage(String imgStr) {
        if (Strings.isNullOrEmpty(imgStr)) {
            return null;
        }
        //转换前端数据
        imgStr = imgStr.replaceAll(" ", "+");
        //去除多余部分
//        imgStr = imgStr.replace("data:text/plain;base64,", "");
        try {
            // Base64解码
            byte[] b = Base64.getDecoder().decode(imgStr);
            for (int i = 0; i < b.length; i++) {
                if (b[i] < 0) {// 调整异常数据
                    b[i] += 256;
                }
            }
            String filepath = "/Users/lidongdong/Downloads/" + System.currentTimeMillis() + ".docx";
            File file = new File(filepath);
            if (file.exists()) {
                file.delete();
            }
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(b);
            fos.flush();
            fos.close();
            return filepath;

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) throws ParseException {
        String imgStr = "UEsDBBQACAgIAAGY11AAAAAAAAAAAAAAAAALAAAAX3JlbHMvLnJlbHOtkt1KAzEQRu/7FGHuu9lW\nEZGmvRGhdyL1AYZk9gc3mZBMtb69QQV12YUKvQyTOd/hYza7kx/UK6XcczCwqmpQFCy7PrQGng8P\ny1tQWTA4HDiQgcCw2y42TzSglJXc9TGrwgjZQCcS77TOtiOPueJIoUwaTh6lPFOrI9oXbEmv6/pG\np98MGEHV3hlIe7cCdcDUkhh44+S0Y3v0FKQq5DJ6j3ROLjdNb+n+e3cifvQD9IzO+kenmDwmLquW\nE/1PZ74G7UnQoeAndRlLACXpKc8aXU0YYYyX7odOQsGRO0fpeqqkYxb2l7b6oo6d9J/r3C4+AFBL\nBwh+xr0Y8gAAAOUCAABQSwMEFAAICAgAAZjXUAAAAAAAAAAAAAAAABMAAABbQ29udGVudF9UeXBl\nc10ueG1stVTLbsIwELzzFZGvVWLooaoqAoc+ji1SqdSrcTZg1Y/IXl5/33UCUcWjomq4RLZmdmZ2\nHXs43hidrMAH5WzOBlmfJWClK5Sd5+xj+pLesySgsIXQzkLOrGPjUW843VYQEqq1IWcLxOqB8yAX\nYETIXAWWkNJ5I5C2fs4rIb/EHPhtv3/HpbMIFlOMGozEnqAUS43JYwNE7ZyJqtJKCqRcfGWLA9V0\np5h50DUnLFQVb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AAAAAAAAAAAAACwBAAAY3VzdG9t\nWG1sL2l0ZW1Qcm9wczEueG1sUEsBAhQAFAAICAgAAZjXULHzsqZmAQAAtAIAABAAAAAAAAAAAAAA\nAAAA2QUAAGRvY1Byb3BzL2FwcC54bWxQSwECFAAUAAgICAABmNdQUHhzv1kBAACVAgAAEQAAAAAA\nAAAAAAAAAAB9BwAAZG9jUHJvcHMvY29yZS54bWxQSwECFAAUAAgICAABmNdQYAqpoe8AAABtAQAA\nEwAAAAAAAAAAAAAAAAAVCQAAZG9jUHJvcHMvY3VzdG9tLnhtbFBLAQIUABQACAgIAAGY11BQ+l2U\nYQkAAAp6AAARAAAAAAAAAAAAAAAAAEUKAAB3b3JkL2RvY3VtZW50LnhtbFBLAQIUABQACAgIAAGY\n11C8l5zAAgEAAMUDAAAcAAAAAAAAAAAAAAAAAOUTAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5y\nZWxzUEsBAhQAFAAICAgAAZjXUGBmRcNPAgAAygcAABIAAAAAAAAAAAAAAAAAMRUAAHdvcmQvZm9u\ndFRhYmxlLnhtbFBLAQIUABQACAgIAAGY11BFgDAjpgUAALIQAAARAAAAAAAAAAAAAAAAAMAXAAB3\nb3JkL3NldHRpbmdzLnhtbFBLAQIUABQACAgIAAGY11Dj9Bf15wkAANZcAAAPAAAAAAAAAAAAAAAA\nAKUdAAB3b3JkL3N0eWxlcy54bWxQSwECFAAUAAgICAABmNdQpC23BscFAACeGwAAFQAAAAAAAAAA\nAAAAAADJJwAAd29yZC90aGVtZS90aGVtZTEueG1sUEsBAhQAFAAICAgAAZjXUEpcwR4BAQAAXAIA\nABQAAAAAAAAAAAAAAAAA0y0AAHdvcmQvd2ViU2V0dGluZ3MueG1sUEsFBgAAAAAPAA8A1QMAABYv\nAAAAAA==";
//        System.out.println(generateImage(imgStr));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        if (new Date().before(sdf.parse("2019-10"))) {
            System.out.println("---------------");
        }
    }
}
